package com.wangzhenyu.learn.test.okhttp_

import com.wangzhenyu.common.util.log.LogUtil

@Suppress("UNUSED")
object NoteOfOkHttp {

    fun test01() {

        val map = mapOf(
            "key" to "free",
            "appid" to "0",
            "msg" to "最给我一次机会吧，求求了"
        )

        val httpApi = OkHttpApi()
        httpApi.get(map, "api.php", object : IHttpCallback {
            override fun onSuccess(data: Any?) {
                LogUtil.default01("success msg: ${data.toString()}")
            }

            override fun onFailed(error: Any?) {
                LogUtil.default01("failed msg: ${error.toString()}")
            }
        })

    }

    fun test02() {
        val httpApi = OkHttpApi()

        httpApi.post(LoginReq(),"",object :IHttpCallback{
            override fun onSuccess(data: Any?) {
                LogUtil.default01("success msg: ${data.toString()}")
            }

            override fun onFailed(error: Any?) {
                LogUtil.default01("failed msg: ${error.toString()}")
            }
        })
    }

    private data class LoginReq(
        val mobile :String = "18648957777",
        val password :String = "cn6123456"
    )
}